<template>
  <div>
    <i class="el-icon-delete" @click="click" />
  </div>
</template>

<script>

import { clearRepeat } from '@/api/remote-search'

export default {
  name: 'ClearBtn',
  beforeDestroy() {
    this.destroy()
  },
  methods: {
    click() {
      this.$confirm('此操作将删除今日重复商品, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 删除
        clearRepeat().then(_ => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          setTimeout(() => {
            window.location.reload()
          }, 3000)
        }).catch(r => {
          this.$message({
            type: 'info',
            message: '删除失败，原因：' + r
          })
        })
      }).catch(() => {
        this.$message({
          type: 'error',
          message: '已取消删除'
        })
      })
    }
  }
}
</script>

<style scoped>
.screenfull-svg {
  display: inline-block;
  cursor: pointer;
  fill: #5a5e66;;
  width: 20px;
  height: 20px;
  vertical-align: 10px;
}
</style>
